package com.yc.thread;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Test9_ReInterrupted extends Thread{
    public static void main(String[] args) throws Exception{
        //当前线程main
        String threadName=Thread.currentThread().getName();

        Test9_ReInterrupted reInterrupt=new Test9_ReInterrupted();//创建线程
        System.out.println(printDate()+threadName+"线程启动");
        //启动新线程
        reInterrupt.start();

        //main主线程休眠3秒
        Thread.sleep(3000);
        //System.out.println(printDate()+threadName+"发出中断信号 设置线程中断");
        //对新线程设置线程中断
        //reInterrupted.interrupt();

        //主线程休眠3秒
        //Thread.sleep(3000);
        System.out.println(printDate()+threadName+"运行结束");
    }

    @Override
    public void run() {
        //
    }

    private static String printDate(){
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
        return sdf.format(new Date())+" ";
    }
}
